package com.example.cookie02.conterller;

import com.example.cookie02.dao.imp.PersonDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author ：lqs
 * @date ：Created in 2023/8/30 15:21
 * @description：
 * @modified By：
 * @version:
 */
@WebServlet("/add")
public class addController extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        PersonDaoImpl personDao = new PersonDaoImpl();
        req.setCharacterEncoding("utf-8");

       Map<String,String[]> mapList = req.getParameterMap();
     boolean add = personDao.add(mapList);
     if (add){
         System.out.println("yes");
     }else {
         System.out.println("no");
     }
        req.getRequestDispatcher("/show").forward(req, resp);


    }
}

